﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.LogEntries.RebellionStartedLogEntry
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using System.Collections.Generic;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Localization;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.LogEntries
{
  public class RebellionStartedLogEntry : LogEntry, IChatNotification
  {
    [SaveableField(310)]
    public readonly Settlement Settlement;
    [SaveableField(311)]
    private readonly bool _isVisibleNotification;

    internal static void AutoGeneratedStaticCollectObjectsRebellionStartedLogEntry(
      object o,
      List<object> collectedObjects)
    {
      ((LogEntry) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
      collectedObjects.Add((object) this.Settlement);
    }

    internal static object AutoGeneratedGetMemberValueSettlement(object o)
    {
      return (object) ((RebellionStartedLogEntry) o).Settlement;
    }

    internal static object AutoGeneratedGetMemberValue_isVisibleNotification(object o)
    {
      return (object) ((RebellionStartedLogEntry) o)._isVisibleNotification;
    }

    public bool IsVisibleNotification => this._isVisibleNotification;

    public override ChatNotificationType NotificationType
    {
      get => this.MilitaryNotification((IFaction) null, (IFaction) this.Settlement.OwnerClan);
    }

    public RebellionStartedLogEntry(Settlement settlement, Clan oldOwnerCLan)
    {
      this.Settlement = settlement;
      this._isVisibleNotification = oldOwnerCLan == Clan.PlayerClan || oldOwnerCLan.Kingdom != null && oldOwnerCLan.Kingdom == Clan.PlayerClan.Kingdom;
    }

    public override string ToString() => this.GetNotificationText().ToString();

    public TextObject GetNotificationText()
    {
      TextObject notificationText = new TextObject("{=fbsFZWhb}Rebels in {SETTLEMENT} have taken the ownership of the settlement.");
      notificationText.SetTextVariable("SETTLEMENT", this.Settlement.Name);
      return notificationText;
    }
  }
}
